/**
 * Author:刘敏
 * Date:2022-09-15
 * Description:服务端入口文件
 */
import { renderToString } from 'vue/server-renderer'
import createApp from './main'
import createStore from '@/store'
const render = async (url: string, manifest: any) => {
  const { app, router } = createApp()

  const pinia = createStore()
  app.use(pinia)

  await router.push(url)
  await router.isReady()
  const ctx: any = {}
  const html = await renderToString(app, ctx)
  const preloadLinks = ""
  const state = JSON.stringify(pinia.state.value)
  console.log("entry-server =>", pinia.state.value)
  return { html, preloadLinks, state }
}
export {
  render
}